import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2024-08-15
 * Time: 14:49
 */
public class demo10 {
    public static void main(String[] args) {
        try (InputStream inputStream = new FileInputStream("./test.txt")) {
            Scanner scanner = new Scanner(inputStream);//Scanner也能传InputStream
            while (scanner.hasNext()) {
                System.out.println(scanner.next());//通过Scanner读取文件内容
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
